// +FHDR------------------------------------------------------------
//                 Copyright (c) 2022 .
//                       ALL RIGHTS RESERVED
// -----------------------------------------------------------------
// Filename      : r_ready_drv.sv
// Author        : 
// Created On    : 2022-08-25 17:36
// Last Modified : 
// -----------------------------------------------------------------
// Description:
//
//
// -FHDR------------------------------------------------------------

`ifndef __R_READY_DRV_SV__
`define __R_READY_DRV_SV__

class r_ready_drv extends uvm_component;
	virtual r_interface vif;
	
	`uvm_component_utils(r_ready_drv)
	
	extern function new(string name = "r_ready_drv", uvm_component parent=null);
	extern virtual function void build_phase(uvm_phase phase);
	extern virtual task main_phase(uvm_phase phase);
endclass: r_ready_drv

function r_ready_drv::new(string name = "r_ready_drv", uvm_component parent=null);
	super.new(name, parent);
endfunction: new

function void r_ready_drv::build_phase(uvm_phase phase);
	super.build_phase(phase);
	`uvm_info("r_ready_drv", "build_phase is called", UVM_LOW);
	if(!uvm_config_db #(virtual r_interface)::get(this, "", "vif", vif))begin
		`uvm_fatal("r_ready_drv", "virtual interface get fatal");
	end
endfunction: build_phase

task r_ready_drv::main_phase(uvm_phase phase);
	fork 
		while(1)begin
            @this.vif.ready_drv;
            randcase
                10:  this.vif.ready = $urandom_range(0,1);
                80:  this.vif.ready = 0;
                10:  this.vif.ready = 1;
            endcase
        end
	join_none
endtask: main_phase

`endif
